package cn.jly.bigdata.spark.core

import org.apache.spark.rdd.RDD
import org.apache.spark.{HashPartitioner, SparkConf, SparkContext}

/**
 * @author lanyangji
 * @date 2019/11/28 13:56
 */
object Spark07_Partition {

  def main(args: Array[String]): Unit = {

    val sc = new SparkContext(new SparkConf().setMaster("local[*]").setAppName("test-checkPoint"))

    val listRdd: RDD[(Int, Int)] = sc.makeRDD(List((1, 1), (2, 2), (3, 3)))

    println(listRdd.partitioner)

    // 设置hash分区
    val partitionedRdd: RDD[(Int, Int)] = listRdd.partitionBy(new HashPartitioner(2))

    println(partitionedRdd.partitioner)

    sc.stop()
  }
}
